//
//  TrainingView.m
//  CoachsBook
//
//  Created by MaBookPro on 2022/8/19.
//

#import "TrainingView.h"

@implementation TrainingView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self CreateUI];
    }
    return self;
}
-(void)CreateUI{
    
    UIView *backview = [[UIView alloc]initWithFrame:CGRectMake(0,0, APPwidth, 120)];
    backview.backgroundColor = [UIColor whiteColor];
    [self addSubview:backview];

    //培训
    UIView *peixunLine = [[UIView alloc]initWithFrame:CGRectMake(15, 15, 3, 15)];
    peixunLine.backgroundColor = rgba(22, 120, 255, 1);
    peixunLine.layer.cornerRadius = 2;
    [backview addSubview:peixunLine];
    UILabel *peixunLab = [[UILabel alloc]initWithFrame:CGRectMake(peixunLine.frame.size.width+peixunLine.frame.origin.x+5, 15, 70, 15)];
    peixunLab.text = @"培训";
    peixunLab.textColor = [UIColor blackColor];
    peixunLab.textAlignment = 0;
    peixunLab.font = [UIFont systemFontOfSize:16 weight:bold];
    [backview addSubview:peixunLab];

    NSArray *peixunArr = @[@"lianche",@"class"];
    NSArray *peixunLabArr = @[@"预约练车",@"我的约课"];
    for (int j = 0; j < peixunArr.count; j++) {
        UIButton *peixunBtn = [[UIButton alloc]initWithFrame: CGRectMake(j*(APPwidth/4), peixunLab.height+peixunLab.y+10, APPwidth/4, 60)];
        peixunBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        peixunBtn.titleLabel.textAlignment = 1;
        [peixunBtn setTitleColor:rgba(51, 51, 51, 1) forState:0];
        [peixunBtn setImage:[UIImage imageNamed:peixunArr[j]] forState:0];
        [peixunBtn setTitle:peixunLabArr[j] forState:0];
        peixunBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 25, 15, 25);
        [peixunBtn.imageView setContentMode:UIViewContentModeScaleAspectFit];
        peixunBtn.titleEdgeInsets = UIEdgeInsetsMake(60, -45, 0, 0);
        [backview addSubview:peixunBtn];

//        if (j == 0) {
//            _liancheBtn = peixunBtn;
//        }else{
//            _classBtn = peixunBtn;
//        }

    }

}
@end
